﻿IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'P_InsertBasicReference')
	BEGIN
		DROP  Procedure  esf_sso.P_InsertBasicReference
	END
GO


CREATE Procedure esf_sso.P_InsertBasicReference
(
	@pBasicReferenceID		BIGINT OUTPUT
	
	,@pBasicReferenceTypeID	INT
	,@pCode					VARCHAR (500)
	,@pName					VARCHAR (500)
	,@pDescription			VARCHAR (1000) = NULL
	,@pExtra_I				VARCHAR (500) = NULL
	,@pExtra_II				VARCHAR (500) = NULL
	,@pExtra_III			VARCHAR (500) = NULL
	,@pIsEnabled			BIT = 1
	
	,@pUserCreationAlias	VARCHAR (20) = 'root'
	,@pCreationDateTime		DATETIME = NULL
)
AS

	IF @pCreationDateTime IS NULL
	BEGIN
		SET @pCreationDateTime = GETDATE ()
	END

	DECLARE @locationID   INT
	
	
	INSERT INTO [esf_sso].[BasicReference]
		([BasicReferenceTypeID], [Code], [Name]
		,[Description], Extra_I, Extra_II
		,Extra_III, [IsEnabled], [CreationDATETIME]
		,[UserCreationAlias])
     VALUES
		(@pBasicReferenceTypeID, @pCode, @pName
		,@pDescription, @pExtra_I, @pExtra_II
		,@pExtra_III, @pIsEnabled, @pCreationDateTime
		,@pUserCreationAlias)
           
	SET @pBasicReferenceID = @@IDENTITY
	
GO